//
//  NavigationBarBackImageView.m
//  NewMusic
//
//  Created by dllo on 15/11/19.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "NavigationBarBackImageView.h"

@interface NavigationBarBackImageView ()
@property(nonatomic, retain) UIImageView *backImage;
@property(nonatomic, retain) UILabel *titleLabel;
@end


@implementation NavigationBarBackImageView
- (void)dealloc {
    [_backImage release];
    [_titleLabel release];
    [_titleString release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        //创建视图
        [self createSubView];
    }
    return self;
}
#pragma mark 创建视图
- (void)createSubView {
    //背景
    self.backImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height )];
    _backImage.image = [UIImage imageNamed:@"nav.jpg"];
    [self addSubview:_backImage];
    [_backImage release];
    //标题
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake((self.frame.size.width - 200) / 2, 20, 200, self.frame.size.height - 20)];
//    _titleLabel.backgroundColor =[UIColor orangeColor];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.font = [UIFont systemFontOfSize:20];
    [self addSubview:_titleLabel];
    [_titleLabel release];
}
#pragma mark 重写titleString 的setter方法
- (void)setTitleString:(NSString *)titleString {
    if (_titleString != titleString) {
        [_titleString release];
        _titleString = [titleString copy];
    }
    _titleLabel.text = titleString;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
